<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title></title>
		<#include "/admin/include/head.htm">
		<script type="text/javascript">
			$(function(){
				$("#confirm").click(function(){
					var amount = parseFloat($("#amount").val());
					if(isNaN(amount) || amount < 0){
						LG.tip("退款金额不正确");
						return;
					}
					
			    	jQuery.ligerDialog.confirm('确定确认吗？', function (confirm) {
		      			if (confirm){
		      				LG.ajax({
								url	: base + '/admin/b2c/refund/confirm.jhtml',
								data: {
									id		: "${refund.id}",
									amount	: amount
								},
								success	: function(){
									LG.showSuccess('确认成功');
					                parent.f_reload();
									parent.$.ligerDialog.close();
									parent.$(".l-dialog,.l-window-mask").css("display","none");
								}
							});
		      			}
		      		});
				});
				
				$("#refuse").click(function(){
			    	jQuery.ligerDialog.confirm('确定拒绝吗？', function (confirm) {
		      			if (confirm){
							LG.ajax({
								url	: base + '/admin/b2c/refund/refuse.jhtml',
								data: {
									id		: "${refund.id}"
								},
								success	: function(){
									LG.showSuccess('拒绝成功');
					                parent.f_reload();
									parent.$.ligerDialog.close();
									parent.$(".l-dialog,.l-window-mask").css("display","none");
								}
							});
		      			}
		      		});
				});
				
				$("#confirmReject").click(function(){
					var amount = parseFloat($("#amount").val());
					if(isNaN(amount) || amount < 0){
						LG.tip("退款金额不正确");
						return;
					}
			    	jQuery.ligerDialog.confirm('确定确认退货吗？', function (confirm) {
		      			if (confirm){
							LG.ajax({
								url	: base + '/admin/b2c/refund/confirmReject.jhtml',
								data: {
									id		: "${refund.id}",
									amount	: amount
								},
								success	: function(){
									LG.showSuccess('确认成功');
					                parent.f_reload();
									parent.$.ligerDialog.close();
									parent.$(".l-dialog,.l-window-mask").css("display","none");
								}
							});
		      			}
		      		});
				});
				
			});
		</script>
		<style type="text/css">
			.item td{
				border:1px solid;
			}
		</style>
	</head>
	<body style="overflow:hidden;padding:10px;">
		<form action="" method="post" id="mainform" class="validate">
			<div id="tabcontainer" style="overflow:hidden;margin:3px;">
				<input type="hidden" name="id" value="${(refund.id)!''}"/>
				<table class="inputTable" style="width:100%;">
					<tr>
						<th>退款编号：</th>
						<td>${refund.refundNo}</td>
						<th>订单编号：</th>
						<td>${refund.orderItem.order.orderNo}</td>
					</tr>
					<tr>
						<th>退款状态：</th>
						<td>${DictionaryUtils.getEnumName(refund.refundStatus)}</td>
						<th>退款金额：</th>
						<td>
							<#if refund.refundStatus = 'apply' || refund.refundStatus = 'delivery'>
								<input type="text" id="amount" value="${refund.subtotal}" class="formText {required:true,number:true,min:0}"/>
							<#else>
								${refund.subtotal}
							</#if>
						</td>
					</tr>
					<tr>
						<th>商品名称：</th>
						<td>${refund.productName}</td>
						<th>商品编号：</th>
						<td>${refund.productCode}</td>
					</tr>
					<tr>
						<th>商品规格：</th>
						<td>${refund.specification}</td>
						<th>商品批号：</th>
						<td>${refund.batch}</td>
					</tr>
					<tr>
						<th>生产日期：</th>
						<td>${(refund.manufacturerDate?string('yyyy-MM-dd'))!}</td>
						<th>有效日期：</th>
						<td>${(refund.validDate?string('yyyy-MM-dd'))!}</td>
					</tr>
					<tr>
						<th>购买价格：</th>
						<td>${refund.salePrice}</td>
						<th>购买数量：</th>
						<td>${refund.quantity}</td>
					</tr>
					<tr>
						<th>联系人：</th>
						<td>${refund.consignee}</td>
						<th>联系电话：</th>
						<td>${refund.contact}</td>
					</tr>
					<tr>
						<th>是否换货：</th>
						<td>${refund.isChange?string('是','否')}</td>
						<#if refund.isChange>
							<th>收货地址：</th>
							<td>${refund.areaName}${refund.address}</td>
						</#if>
					</tr>
					<#if refund.isChange && refund.refundStatus = 'finish'>
						<tr>
							<th>配送方式：</th>
							<td>${refund.deliveryMethodName}</td>
							<th>快递单号：</th>
							<td>${refund.logisticsNo}</td>
						</tr>
						<tr>
							<th>配送费用：</th>
							<td>${refund.shipFee}</td>
						</tr>
					</#if>
					<tr>
						<th>备注：</th>
						<td colspan="3">${refund.remark}</td>
					</tr>
				</table>
				<div style="float: right;margin: 10px 100px 0 0;">
					<#if refund.refundStatus = 'apply'>
						<input type="button" value="确认" class="button" id="confirm"/>
						<input type="button" value="拒绝" class="button" id="refuse"/>
					<#elseif refund.refundStatus = 'delivery'>
						<input type="button" value="确认退货" class="button" id="confirmReject"/>
						<input type="button" value="拒绝" class="button" id="refuse"/>
					</#if>
				</div>
			</div>
		</form>
	</body>
</html>